import processor, roomsupport, string, re

class Dump(object):
    def process(self, command):
        dumpObjectMatch = re.search("^dump visible (.*)$", command)
        dumpAllObjectMatch = re.search("^dump any (.*)$", command)
        if command == "dump room":
            return repr(processor.me.room.__dict__)
        elif command == "dump room contents":
            return string.join([a.nameAsUnknown() for a in processor.me.room.contents], "; ")
        elif command == "dump rooms":
            return repr(roomsupport.rooms)
        if command == "dump hooks":
            return repr(processor.hooks)
        elif command == "dump objects":
            return repr(processor.objects)
        elif command == "dump accessible":
            return repr(processor.accessibleObjects)
        elif command == "dump me":
            return repr(processor.me.__dict__)
        elif dumpObjectMatch:
            return repr(processor.getItem(dumpObjectMatch.group(1)).__dict__)
        elif dumpAllObjectMatch:
            return repr(processor.getItem(dumpAllObjectMatch.group(1), processor.objects).__dict__)

processor.commands.append(Dump())
